package com.shop.cereshop.admin.config;

import com.shop.cereshop.admin.service.config.impl.CereConfigServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 系统启动时加载参数配置到 Redis
 */
@Component
@Slf4j(topic = "ConfigCacheInitializer")
public class ConfigCacheInitializer implements ApplicationRunner {

    @Autowired
    private CereConfigServiceImpl cereConfigService;

    @Override
    public void run(ApplicationArguments args) {
        try {
            cereConfigService.loadAllToRedis();
        } catch (Exception e) {
            log.error("启动加载系统参数配置到Redis失败", e);
        }
    }
}


